<template>
  <Container>
    <!-- 基础设置 -->
    <div class="container-header title title-center" slot="header">
      季度积分返利审核
      <Button
        size="large"
        class="fl btn-back"
        icon="ios-arrow-back"
        @click="jumpPrevPage"
      >返回</Button>
    </div>
    <DefaultEditItem ref="defaultForm" :id="id" :isCheck="isCheck"></DefaultEditItem>
    <div class="container-footer bg-white" slot="footer" v-if="isCheck">
      <Button type="primary" size="large" @click="onSave" :disabled="disabled">审核</Button>
    </div>
  </Container>
</template>
<script>
  import DefaultEditItem from "./edit/DefaultEditItem"
  export default {
    name: "",
    components: {
      DefaultEditItem
    },
    data() {
      return {
        id: this.$route.query.id,
        disabled: false,
        isCheck: this.$route.query.from === 'check' ? true : false
      }
    },
    methods: {
      jumpPrevPage() {
        this.$router.back()
      },
      onSave() {
        this.disabled = true
        let formData = this.$refs["defaultForm"].form
        let param = {
          id: this.id,
          auditIntegralRemark: formData.auditIntegralRemark,
          auditRebateRemark: formData.auditRebateRemark,
          auditRebate: formData.quarterRepairRebate,
          auditIntegral: formData.quarterRepairIntegral
        }
        this.$jsonPost(`/assets/store_int_quarter/audit`, param).then(() => {
          this.$Notice.success({
            title: `审核成功`
          })
          setTimeout(() => {
            this.$router.replace('/welfare/integralQuarter/list')
          }, 200)
        }).catch(() => {
          this.$Notice.success({
            title: `审核失败`
          })
          this.disabled = false
        })
      }
    }
  };
</script>

